home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
chkflp.exe
/
CFLOP.ASM
< prev
next >
Wrap
Assembly Source File
|
1991-12-05
|
8KB
|
201 lines
; File......: FLOPTST.ASM
; Author....: Joseph LaCour
; Date......: $Date: 15 Aug 1991 23:07:48 $
; Revision..: $Revision: 1.2 $
; Log file..: $Logfile: E:/nanfor/src/floptst.asv $
;
; This is an original work by Joseph LaCour and is placed in the
; public domain.
;
;
; ACKNOWLEDGEMENTS:
;
; PAOLO RAMOZZI FOR HIS WORK IN DBDCHECK FOR SHOWING HOW TO
; USE INT 13H.
;
;
; Modification history:
; ---------------------
;
; $Log: E:/nanfor/src/floptst.asv $
;
: Rev 2.0 04 Dec 1991 09:16:00 Kevin Traub
; Modified to be a 'c' callable function. Calling convention:
; extern unsigned far ft_floptst(int drivenumber);
; Removed Clipper interface, and removed check for invalid parameters to
; reduce overhead. Clipper Program was about 115k, 'c' .exe is now about 4k.
; use MS Masm 5.1 or higher to assemble - No arguments, Model already defined
; as Large.
; Compile accompanying 'c' pgm as large model and link with defaults
; eg: masm cflop.asm;
; cl /AL /c callclp.c
; link callcflp.obj+cflop.obj;
;
; Executable callcflp will set DOS ERRORLEVEL based on condition of specified
; floppy. eg. callcflp A - will test drive A for readiness, if drive is
; not ready (Door open or no disk) .exe will set ERRORLEVEL to 1, and will
; temporarily (duration of callcflp.exe) intercept DOS critical error handler
; so there will be no RETRY,IGNORE,ABORT, FAIL? message.
; ERRORLEVELS set as follows:
; 0 - Drive Loaded and ready to read or write
; 1 - Drive Door Open or Diskette inserted upside down
; 2 - Diskette is unformatted
; 3 - Write protected
; 4 - Undetermined
; Arguments to callcflp.exe are A or B, case insensitive, : not necessary.
;
; Rev 1.2 15 Aug 1991 23:07:48 GLENN
; Forest Belt proofread/edited/cleaned up doc
;
; Rev 1.1 11 May 1991 00:21:42 GLENN
; File header changed to conform to Toolkit standard.
;
; $DESCRIPTION$
; FT_FLOPTST() returns a numeric code designating the
; diskette drive's status.
;
; FT_FLOPTST() is particularly useful in backup and restore programs
; that need to test the floppy drive before writing/reading from a
; floppy disk.
.MODEL LARGE
_FT_DATASEG SEGMENT PUBLIC 'DATA'
FDRIVE DB 0
BOOT_SECT DB 512 DUP (0)
_FT_DATASEG ENDS
_NANFOR SEGMENT 'CODE'
ASSUME CS:_NANFOR,DS:_FT_DATASEG,ES:_FT_DATASEG,SS:NOTHING
public _ft_floptst
_ft_floptst proc far
push bp ; Entry sequence - save old BP
mov bp,sp ; Set stack framepointer
mov ax,[bp+6] ; Load Arg2 into AX
push ax ; save drive
PUSH AX
int 11h ; get equipment list
mov ah,0 ; clear high byte
mov cl,6 ; set shift count
shr al,cl ; shift diskette count
pop bx ; restore drive
cmp bl,al ; does drive exist?
jbe ParamOk ; yes, so continue
derror: jmp short Ferror ; Invalid drive
ParamOk:
POP AX
push ds ; Save DS
mov dx,_FT_DATASEG ; DATA SEGMENT
MOV DS,DX ; IN DS REGISTER
MOV ES,DX ; IN ES REGISTER
MOV FDRIVE,AL ; SAVE DRIVE NUMBER
XOR AX,AX ; RESET DISKETTE SYSTEM
INT 13H ; CALL BIOS
CALL _FTFLOPT ; TEST DISKETTE TYPE
POP DS ; RESTORE DS
JMP SHORT EXIT ; RETURN
FERROR:
MOV AX,-1 ; BAD PARAMETERS
EXIT:
; Leave return value in AX
pop bp ; Restore old framepointer
ret 4 ; Exit, and restore 4 bytes of args
_ft_floptst endp
;-----------------------------------------------------------;
; LOCAL SUBROUTINE - CALL BIOS INT 13 FOR READ SECTOR ;
;-----------------------------------------------------------;
_FTINT13 PROC NEAR
PUSH BX ; SAVE REGS
PUSH ES ;
PUSH AX ;
INT 13H ; CALL BIOS (read sector)
jnc ftIntRet ; Read ok. Exit
xor ax,ax ; reset diskette system
int 13h ; call BIOS
pop ax ; restore regs
pop es ; for retry
push es ; save regs
push ax ;
int 13h ; call BIOS (read sector)
jnc ftIntRet ; Read ok. Exit
xor ax,ax ; reset diskette system
int 13h ; call BIOS
pop ax ; restore regs
pop es ; for retry
push es ; save regs
push ax ;
int 13h ; call BIOS (read sector)
ftIntRet: pop bx ; restore regs
pop es ;
pop bx ;
ret ; near return
_ftint13 endp
;-----------------------------------------------------------;
; Local subroutine - check boot sector ;
;-----------------------------------------------------------;
_ftflopt proc near
push di ; preserve
mov di,OFFSET _FT_DataSeg:boot_sect ; address of buffer
ftflopred:
xor dx,dx ; clear DX
mov dl,fdrive ; drive number in DL
mov cx,0001h ; track 0, sector 1
mov bx,di ; buffer addr in ES:BX
mov ax,0201h ; read one sector
call _ftint13 ; call BIOS
jnc Flop1 ; Read ok. Continue
cmp ah,80h ; drive not ready ?
je Flop_out ; Yes.
cmp ah,02h ; unformatted?
je Flop_for ; Yes
mov ax,4 ; otherwise, unknown
jmp short Flop_End ; and exit
Flop1:
xor dx,dx ; clear DX
mov dl,fdrive ; drive number in DL
mov cx,0001h ; track 0, sector 1
mov bx,di ; buffer addr in ES:BX
mov ax,0301h ; write one sector
call _ftint13 ; call BIOS
jnc Flop_OK ; Write ok. Disk s/b AOK
cmp ah,03h ; Write protected?
jne Flop_OK ; No disk AOK
mov ax,3
jmp short Flop_End
Flop_out:
mov ax,1
jmp short Flop_End
Flop_for:
mov ax,2
jmp short Flop_End
Flop_OK:
xor ax,ax ; AX = 0
Flop_End:
pop di ; restore
ret ; near return
_ftflopt endp
_nanfor ends
end